varying vec3 out_norm;
varying vec3 out_pos;

//float whiten(float c) {
//    float k = c;
//    return (1.0*k + c*(1.0 - k))/k;
//}

void main(void)
{
    vec3 dir_light_dir = vec3(-1.0, -1.0, -1.0);
    vec3 dir_light_base_color = vec3(0.3, 0.3, 0.4);

    float shade_level_dir = abs(dot(dir_light_dir, out_norm));
    vec3 shaded_color_dir = dir_light_base_color*shade_level_dir;

//    vec3 dir_light_dir2 = vec3(1.0, 1.0, -1.0);
    vec3 dir_light_dir2 = vec3(1.0, 1.0, -1.0);
    vec3 dir_light_base_color2 = vec3(0.3, 0.3, 0.4);

//    float shade_level_dir2 = abs(dot(dir_light_dir2, out_norm));
    float shade_level_dir2 = cos(1.0 - abs(dot(dir_light_dir2, out_norm)))*1.5;
    vec3 shaded_color_dir2 = dir_light_base_color2*shade_level_dir2*shade_level_dir2*shade_level_dir2;

//    vec3 point_light_point = vec3(4.0, 4.0, 4.0);
//    vec3 point_light_base_color = vec3(0.3, 0.3, 0.4);

//    vec3 point_light_dir = normalize(out_pos - point_light_point);

//    float shade_level_point = dot(point_light_dir, out_norm);
//    vec3 shaded_color_point = point_light_base_color*shade_level_point;

    vec3 extra_color = vec3(0.1, 0.1, 0.1);

    vec3 shaded_color = shaded_color_dir*1.2
            + shaded_color_dir2*0.4
//            + shaded_color_point
            + extra_color;
//    shaded_color.r = whiten(shaded_color.r);
//    shaded_color.g = whiten(shaded_color.g);
//    shaded_color.b = whiten(shaded_color.b);

      gl_FragColor = vec4(shaded_color, 1.0);
  //  gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
